#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from celery import Celery
from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'book_collection.settings')
# 任务存放的地方
app = Celery('book', broker='redis://:123456@127.0.0.1:6379/1', backend='redis://:123456@127.0.0.1:6379/15')
app.config_from_object('django.conf:settings')
# 定义定时任务
app.conf.beat_schedule = {
    'send-borrow-info': {
        'task': 'book_app.tasks.loan_period_reminder',
        'schedule': crontab(hour=8, minute=0),  # 每天 08:00 执行
    },
}

# 自动发现任务并执行
app.autodiscover_tasks()
